﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserAreaRights.aspx.cs" Inherits="UserAreaRights" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>店铺资料</title>
    <script src="../js/extTools.js" type="text/javascript"></script>
    <style>
        .x-grid-row-over .x-grid-cell-inner
        {
            font-weight: bold;
        }
        .x-column-header-inner
        {
            height: 28px;
            background: #E7EBEF url(./images/header.png) repeat-x 0 0;
        }
    </style>
    <script>
        var CountrySelector = {
            add: function (source, destination) {
                source = source || GridPanel1;
                destination = destination || GridPanel2;
                if (source.selModel.hasSelection()) {
                    var records = source.selModel.getSelection();
                    source.store.remove(records);
                    destination.store.add(records);
                }
            },
            addAll: function (source, destination) {
                source = source || GridPanel1;
                destination = destination || GridPanel2;
                var records = source.store.getRange();
                source.store.removeAll();
                destination.store.add(records);
            },
            addByName: function (name) {
                if (!Ext.isEmpty(name)) {
                    var result = Store1.queryBy(function (r) {
                        return r.get("Name") === name;
                    });
                    if (!Ext.isEmpty(result.items)) {
                        GridPanel1.store.remove(result.items[0]);
                        GridPanel2.store.add(result.items[0]);
                    }
                }
            },
            addByNames: function (name) {
                for (var i = 0; i < name.length; i++) {
                    this.addByName(name[i]);
                }
            },
            remove: function (source, destination) {
                this.add(destination, source);
            },
            removeAll: function (source, destination) {
                this.addAll(destination, source);
            }
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Default" />
        <ext:Viewport runat="server" Layout="FitLayout">
            <Items>
                <ext:Panel runat="server" Title="用户区域权限" Layout="HBoxLayout">
                    <LayoutConfig>
                        <ext:HBoxLayoutConfig Align="Stretch" />
                    </LayoutConfig>
                    <Items>
                        <ext:GridPanel runat="server" ID="GridPanel3" Width="300">
                            <Store>
                                <ext:Store ID="Store1" runat="server">
                                    <Model>
                                        <ext:Model runat="server" IDProperty="UserID">
                                            <Fields>
                                                <ext:ModelField Name="UserID" />
                                                <ext:ModelField Name="UserCode" />
                                                <ext:ModelField Name="UserName" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <ColumnModel ID="ColumnModel3" runat="server">
                                <Columns>
                                    <ext:Column ID="Column4" runat="server" Text="用户编号" DataIndex="UserCode">
                                        <Filter>
                                            <ext:StringFilter />
                                        </Filter>
                                    </ext:Column>
                                    <ext:Column ID="Column3" runat="server" Text="用户列表" DataIndex="UserName" Flex="1">
                                        <Filter>
                                            <ext:StringFilter />
                                        </Filter>
                                    </ext:Column>
                                </Columns>
                            </ColumnModel>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="RowSelectionModel3" runat="server">
                                    <DirectEvents>
                                        <Select OnEvent="Cell_Click">
                                            <EventMask ShowMask="true" Msg="加载权限中...">
                                            </EventMask>
                                        </Select>
                                    </DirectEvents>
                                </ext:RowSelectionModel>
                            </SelectionModel>
                            <Plugins>
                                <ext:GridFilters ID="GridFilters2" runat="server" />
                            </Plugins>
                            <BottomBar>
                                <ext:PagingToolbar ID="PagingToolbar1" runat="server">
                                    <Items>
                                        <ext:Label ID="Label1" runat="server" Text="每页显示:" />
                                        <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                                    </Items>
                                    <Plugins>
                                        <ext:ProgressBarPager ID="ProgressBarPager1" runat="server" />
                                    </Plugins>
                                </ext:PagingToolbar>
                            </BottomBar>
                        </ext:GridPanel>
                        <ext:Panel ID="Panel4" runat="server" Width="35" BodyStyle="background-color: transparent;"
                            Border="false" Layout="Anchor" />
                        <ext:GridPanel runat="server" ID="GridPanel1" Flex="1">
                            <Store>
                                <ext:Store ID="Store2" runat="server">
                                    <Model>
                                        <ext:Model ID="Model1" runat="server" IDProperty="OperationAreaID">
                                            <Fields>
                                                <ext:ModelField Name="OperationAreaID" />
                                                <ext:ModelField Name="OperationAreaName" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <ColumnModel ID="ColumnModel1" runat="server">
                                <Columns>
                                    <ext:Column ID="Column1" runat="server" Text="待选权限" DataIndex="OperationAreaName"
                                        Flex="1">
                                        <Filter>
                                            <ext:StringFilter />
                                        </Filter>
                                    </ext:Column>
                                </Columns>
                            </ColumnModel>
                            <View>
                                <ext:GridView ID="GridView1" runat="server" EmptyText="没有数据！" />
                            </View>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Multi" />
                            </SelectionModel>
                            <Plugins>
                                <ext:GridFilters ID="GridFilters1" runat="server" />
                            </Plugins>
                        </ext:GridPanel>
                        <ext:Panel ID="Panel1" runat="server" Width="35" BodyStyle="background-color: transparent;"
                            Border="false" Layout="Anchor">
                            <Items>
                                <ext:Panel ID="Panel2" runat="server" Border="false" BodyStyle="background-color: transparent;"
                                    AnchorVertical="40%" />
                                <ext:Panel ID="Panel3" runat="server" Border="false" BodyStyle="background-color: transparent;"
                                    BodyPadding="5">
                                    <Items>
                                        <ext:Button ID="Button1" runat="server" Icon="ResultsetNext" StyleSpec="margin-bottom:2px;">
                                            <DirectEvents>
                                                <Click OnEvent="Btn_Add" />
                                            </DirectEvents>
                                            <ToolTips>
                                                <ext:ToolTip ID="ToolTip1" runat="server" Title="Add" Html="Add Selected Rows" />
                                            </ToolTips>
                                        </ext:Button>
                                        <ext:Button ID="Button2" runat="server" Icon="ResultsetLast" StyleSpec="margin-bottom:2px;">
                                            <Listeners>
                                                <Click Handler="CountrySelector.addAll();" />
                                            </Listeners>
                                            <ToolTips>
                                                <ext:ToolTip ID="ToolTip2" runat="server" Title="Add all" Html="Add All Rows" />
                                            </ToolTips>
                                        </ext:Button>
                                        <ext:Button ID="Button3" runat="server" Icon="ResultsetPrevious" StyleSpec="margin-bottom:2px;">
                                              <DirectEvents>
                                                <Click OnEvent="Btn_Delete" />
                                            </DirectEvents>
                                            <ToolTips>
                                                <ext:ToolTip ID="ToolTip3" runat="server" Title="移除" Html="移除当前选中的数据" />
                                            </ToolTips>
                                        </ext:Button>
                                        <ext:Button ID="Button4" runat="server" Icon="ResultsetFirst" StyleSpec="margin-bottom:2px;">
                                            <Listeners>
                                                <Click Handler="CountrySelector.removeAll(GridPanel1, GridPanel2);" />
                                            </Listeners>
                                            <ToolTips>
                                                <ext:ToolTip ID="ToolTip4" runat="server" Title="Remove all" Html="Remove All Rows" />
                                            </ToolTips>
                                        </ext:Button>
                                    </Items>
                                </ext:Panel>
                            </Items>
                        </ext:Panel>
                        <ext:GridPanel runat="server" ID="GridPanel2" EnableDragDrop="false" Flex="1">
                            <Store>
                                <ext:Store ID="Store3" runat="server">
                                    <Model>
                                        <ext:Model ID="Model2" runat="server" IDProperty="SourceID">
                                            <Fields>
                                                <ext:ModelField Name="SourceID" />
                                                <ext:ModelField Name="SourceName" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <ColumnModel ID="ColumnModel2" runat="server">
                                <Columns>
                                    <ext:Column ID="Column2" runat="server" Text="已选权限" DataIndex="SourceName" Flex="1" />
                                </Columns>
                            </ColumnModel>
                            <View>
                                <ext:GridView ID="GridView2" runat="server" EmptyText="没有数据！" />
                            </View>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" Mode="Multi" />
                            </SelectionModel>
                        </ext:GridPanel>
                    </Items>
                    <Buttons>
                        <ext:Button ID="Button5" runat="server" Text="Save Selected Countries" Icon="Disk">
                            <Listeners>
                                <Click Handler="#{GridPanel2}.submitData();" />
                            </Listeners>
                        </ext:Button>
                        <ext:Button ID="Button6" runat="server" Text="Cancel" Icon="Cancel">
                            <Listeners>
                                <Click Handler="CountrySelector.removeAll(GridPanel1, GridPanel2);" />
                            </Listeners>
                        </ext:Button>
                    </Buttons>
                </ext:Panel>
            </Items>
        </ext:Viewport>
    </div>
    </form>
</body>
</html>
